#include "pagemaintnetwork.h"
#include "ui_pagemaintnetwork.h"

PageMaintNetwork::PageMaintNetwork(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PageMaintNetwork)
{
    ui->setupUi(this);
    setAutoFillBackground(true);  //设置自动填充
    QPalette palette = BKGCLR;
    setPalette(palette);

    PageNetwork *network1 = new PageNetwork(Network_BlueAndRed,this);
    network1->setGeometry(0,0,1220,550);
    network_stat_list_.append(network1);

    PageNetwork *network2 = new PageNetwork(Network_Red,this);
    network2->setGeometry(0,0,1220,550);
    network2->hide();
    network_stat_list_.append(network2);

    PageNetwork *network3 = new PageNetwork(Network_Blue,this);
    network3->setGeometry(0,0,1220,550);
    network3->hide();
    network_stat_list_.append(network3);
}

PageMaintNetwork::~PageMaintNetwork()
{
    delete ui;
}

void PageMaintNetwork::on_Btn_BlueAndRed_clicked()
{
    for (int i=0;i<3 ;i++ ) {
        network_stat_list_[i]->setVisible(i==Network_BlueAndRed);
    }
}

void PageMaintNetwork::on_Btn_Red_clicked()
{
    for (int i=0;i<3 ;i++ ) {
        network_stat_list_[i]->setVisible(i==Network_Red);
    }
}

void PageMaintNetwork::on_Btn_Blue_clicked()
{
    for (int i=0;i<3 ;i++ ) {
        network_stat_list_[i]->setVisible(i==Network_Blue);
    }
}

void PageMaintNetwork::on_Btn_Return_clicked()
{
    emit returnToMaintMenu();
}

void PageMaintNetwork::setDeviceComStatus(int type,int dev, int index, bool flt, bool master)
{
    if(type > Network_Blue)
        return;
    network_stat_list_[type]->setDeviceComStatus(dev,index,flt,master);
}

void PageMaintNetwork::setTCDSVisible(int type, bool xVisible)
{
    if(type > Network_Blue)
        return;
    network_stat_list_[type]->setTCDSVisible(xVisible);
}
